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

Z Wiki JU
Ofara (diskuse | příspěvky)
Bez shrnutí editace
Ofara (diskuse | příspěvky)
Bez shrnutí editace
Řádek 58: Řádek 58:
   setTimeout(function () { injectNote(); obs.disconnect(); }, 5000);
   setTimeout(function () { injectNote(); obs.disconnect(); }, 5000);
})();
})();
mw.loader.using('mediawiki.searchSuggest', function() {
  // Najdi box s rozšířeným vyhledáváním a rozbal ho
  var advanced = document.querySelector('.mw-search-nsoptions');
  if (advanced) {
    advanced.style.display = 'block';
  }
  // Skrýt tlačítko "Rozšířené"
  var toggle = document.querySelector('.mw-search-togglebox');
  if (toggle) {
    toggle.style.display = 'none';
  }
});

Verze z 25. 9. 2025, 07:20

/* Zde uvedený JavaScript bude použit pro všechny uživatele při načtení každé stránky */

$(function () {
  // Zruš jQuery UI vzhled tlačítka
  $('.articleFeedbackv5-submit').button('destroy');
});

document.addEventListener('DOMContentLoaded', function () {
  document.querySelectorAll('.extern-download').forEach(el => {
    el.style.cursor = 'pointer';
    el.style.color = '#0645AD';
    el.style.textDecoration = 'underline';
    el.addEventListener('click', () => {
      const a = document.createElement('a');
      a.href = el.getAttribute('data-url');
      a.setAttribute('download', '');
      a.style.display = 'none';
      document.body.appendChild(a);
      a.click();
      document.body.removeChild(a);
    });
  });
});

(function () {
  var NOTE_ID = 'af5-note';
  var NOTE_HTML =
    '<div id="' + NOTE_ID + '" class="articleFeedbackv5-note">' +
      '<b>Tento formulář slouží pouze jako zpětná vazba pro tuto stránku.</b> ' +
      'Řešíte-li nějaký problém, napište e-mail na ' +
      '<a href="/Servicedesk/Seznam_e-mailových_adres_pro_zadávání_požadavků">službu,</a> které se Váš problém týká.' +
    '</div>';

   function injectNote(root) {
    var $title = (root ? $(root) : $(document))
      .find('.articleFeedbackv5-title-wrap')
      .first();

    if (!$title.length) return false;                 // nadpis není
    if (document.getElementById(NOTE_ID)) return true; // už vloženo

    $title.after(NOTE_HTML);                          // vložit pod nadpis
    return true;
  }

  if (injectNote()) return;

  var obs = new MutationObserver(function (mutations) {
    for (var m of mutations) {
      if (injectNote(m.target)) {
        obs.disconnect();
        break;
      }
    }
  });

  obs.observe(document.body, { childList: true, subtree: true });
  setTimeout(function () { injectNote(); obs.disconnect(); }, 5000);
})();

mw.loader.using('mediawiki.searchSuggest', function() {
  // Najdi box s rozšířeným vyhledáváním a rozbal ho
  var advanced = document.querySelector('.mw-search-nsoptions');
  if (advanced) {
    advanced.style.display = 'block';
  }

  // Skrýt tlačítko "Rozšířené"
  var toggle = document.querySelector('.mw-search-togglebox');
  if (toggle) {
    toggle.style.display = 'none';
  }
});