MediaWiki:Common.js: Porovnání verzí
Z Wiki JU
Bez shrnutí editace |
Bez shrnutí editace |
||
| Řádek 63: | Řádek 63: | ||
//Vyhledávání | //Vyhledávání | ||
/* Special:Search – profil | /* Special:Search – advanced profil + skrývání nepotřebných NS (OOUI řádky) */ | ||
(function () { | (function () { | ||
if (mw.config.get('wgCanonicalSpecialPageName') !== 'Search') return; | if (mw.config.get('wgCanonicalSpecialPageName') !== 'Search') return; | ||
// 1) | // 1) vynutit profil=advanced | ||
const url = new URL(location.href); | |||
if (url.searchParams.get('profile') !== 'advanced') { | if (url.searchParams.get('profile') !== 'advanced') { | ||
url.searchParams.set('profile', 'advanced'); | url.searchParams.set('profile', 'advanced'); | ||
| Řádek 75: | Řádek 75: | ||
} | } | ||
// 2) | // 2) seznam input ID, které CHCEME SCHOVAT | ||
const HIDE_IDS = [ | |||
'mw-search-ns1','mw-search-ns2','mw-search-ns3','mw-search-ns4','mw-search-ns5', | |||
'mw-search-ns8','mw-search-ns9','mw-search-ns11','mw-search-ns12','mw-search-ns13', | |||
'mw-search-ns420','mw-search-ns421','mw-search-ns828','mw-search-ns829', | |||
'mw-search-ns3000','mw-search-ns3001','mw-search-ns3004','mw-search-ns3005', | |||
'mw-search-ns1','mw-search-ns2','mw-search- | |||
'mw-search-ns3006','mw-search-ns3007' | 'mw-search-ns3006','mw-search-ns3007' | ||
]; | ]; | ||
function | // 3) pomocná funkce – skryje celé řádky s danými checkboxy | ||
function hideNamespaceRows() { | |||
const root = document.querySelector('.mw-search-nsoptions'); | |||
if (!root) return; | if (!root) return; | ||
HIDE_IDS.forEach(id => { | |||
const input = document.getElementById(id); | |||
if (row | if (!input) return; | ||
const row = input.closest('.oo-ui-fieldLayout'); // celý řádek OOUI | |||
if (row) row.style.display = 'none'; | |||
}); | }); | ||
} | } | ||
// | // 4) čekej, až se OOUI volby opravdu vykreslí, pak skryj | ||
mw.hook('wikipage.content').add( | function whenReadyDo(fn) { | ||
const check = () => { | |||
const ready = document.querySelector('.mw-search-nsoptions .oo-ui-fieldLayout'); | |||
if (ready) { fn(); return true; } | |||
return false; | |||
}; | |||
if (check()) return; | |||
const obs = new MutationObserver(() => { if (check()) obs.disconnect(); }); | |||
obs.observe(document.body, { childList: true, subtree: true }); | |||
} | |||
// 5) (vol.) schovej lištu profilů nahoře | |||
mw.hook('wikipage.content').add($c => { | |||
$c.find('.mw-search-profile-tabs').hide(); // smaž, pokud ji chceš ponechat | |||
}); | |||
// | // 6) poprvé a pak po každém přestavení DOMu (Všechno/Nic apod.) | ||
whenReadyDo(hideNamespaceRows); | |||
const rebinder = new MutationObserver(hideNamespaceRows); | |||
rebinder.observe(document.body, { childList: true, subtree: true }); | |||
})(); | })(); | ||
Verze z 25. 9. 2025, 07:46
/* Zde uvedený JavaScript bude použit pro všechny uživatele při načtení každé stránky */
//Zpětná vazba
$(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);
})();
//Vyhledávání
/* Special:Search – advanced profil + skrývání nepotřebných NS (OOUI řádky) */
(function () {
if (mw.config.get('wgCanonicalSpecialPageName') !== 'Search') return;
// 1) vynutit profil=advanced
const url = new URL(location.href);
if (url.searchParams.get('profile') !== 'advanced') {
url.searchParams.set('profile', 'advanced');
location.replace(url.toString());
return;
}
// 2) seznam input ID, které CHCEME SCHOVAT
const HIDE_IDS = [
'mw-search-ns1','mw-search-ns2','mw-search-ns3','mw-search-ns4','mw-search-ns5',
'mw-search-ns8','mw-search-ns9','mw-search-ns11','mw-search-ns12','mw-search-ns13',
'mw-search-ns420','mw-search-ns421','mw-search-ns828','mw-search-ns829',
'mw-search-ns3000','mw-search-ns3001','mw-search-ns3004','mw-search-ns3005',
'mw-search-ns3006','mw-search-ns3007'
];
// 3) pomocná funkce – skryje celé řádky s danými checkboxy
function hideNamespaceRows() {
const root = document.querySelector('.mw-search-nsoptions');
if (!root) return;
HIDE_IDS.forEach(id => {
const input = document.getElementById(id);
if (!input) return;
const row = input.closest('.oo-ui-fieldLayout'); // celý řádek OOUI
if (row) row.style.display = 'none';
});
}
// 4) čekej, až se OOUI volby opravdu vykreslí, pak skryj
function whenReadyDo(fn) {
const check = () => {
const ready = document.querySelector('.mw-search-nsoptions .oo-ui-fieldLayout');
if (ready) { fn(); return true; }
return false;
};
if (check()) return;
const obs = new MutationObserver(() => { if (check()) obs.disconnect(); });
obs.observe(document.body, { childList: true, subtree: true });
}
// 5) (vol.) schovej lištu profilů nahoře
mw.hook('wikipage.content').add($c => {
$c.find('.mw-search-profile-tabs').hide(); // smaž, pokud ji chceš ponechat
});
// 6) poprvé a pak po každém přestavení DOMu (Všechno/Nic apod.)
whenReadyDo(hideNamespaceRows);
const rebinder = new MutationObserver(hideNamespaceRows);
rebinder.observe(document.body, { childList: true, subtree: true });
})();