MediaWiki:Common.js: Porovnání verzí
Vzhled
Bez shrnutí editace |
Bez shrnutí editace značka: ruční vrácení zpět |
||
| (Není zobrazeno 6 mezilehlých verzí od stejného uživatele.) | |||
| Řádek 1: | Řádek 1: | ||
mw.loader.using(['mediawiki.util'], function () { | |||
(function () { | $(function () { | ||
function | |||
function createSwitcher() { | |||
if ($('#lang-switcher').length) return; | |||
$('body').append( | |||
'<div id="lang-switcher" style="position:fixed;top:10px;right:10px;z-index:9999;background:#fff;padding:6px 12px;border:1px solid #ccc;border-radius:6px;font-size:14px;box-shadow:0 2px 6px rgba(0,0,0,0.2);">' + | |||
'<a href="#" id="lang-cs">Čeština</a> | ' + | |||
'<a href="#" id="lang-en">English</a>' + | |||
'</div>' | |||
); | |||
$('#lang-en').click(function (e) { | |||
e.preventDefault(); | |||
document.cookie = "googtrans=/cs/en;path=/"; | |||
location.reload(); | |||
}); | |||
$('#lang-cs').click(function (e) { | |||
})(); | e.preventDefault(); | ||
document.cookie = "googtrans=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;"; | |||
location.reload(); | |||
}); | |||
} | |||
function loadGoogle() { | |||
if ($('#google_translate_element').length) return; | |||
$('body').append('<div id="google_translate_element" style="display:none;"></div>'); | |||
window.googleTranslateElementInit = function () { | |||
new google.translate.TranslateElement({ | |||
pageLanguage: 'cs', | |||
includedLanguages: 'cs,en', | |||
autoDisplay: false | |||
}, 'google_translate_element'); | |||
}; | |||
$.getScript('https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit'); | |||
} | |||
createSwitcher(); | |||
loadGoogle(); | |||
// Reinforce switcher after translation DOM rewrite | |||
setTimeout(createSwitcher, 2000); | |||
}); | |||
}); | |||
Aktuální verze z 21. 2. 2026, 22:11
mw.loader.using(['mediawiki.util'], function () {
$(function () {
function createSwitcher() {
if ($('#lang-switcher').length) return;
$('body').append(
'<div id="lang-switcher" style="position:fixed;top:10px;right:10px;z-index:9999;background:#fff;padding:6px 12px;border:1px solid #ccc;border-radius:6px;font-size:14px;box-shadow:0 2px 6px rgba(0,0,0,0.2);">' +
'<a href="#" id="lang-cs">Čeština</a> | ' +
'<a href="#" id="lang-en">English</a>' +
'</div>'
);
$('#lang-en').click(function (e) {
e.preventDefault();
document.cookie = "googtrans=/cs/en;path=/";
location.reload();
});
$('#lang-cs').click(function (e) {
e.preventDefault();
document.cookie = "googtrans=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
location.reload();
});
}
function loadGoogle() {
if ($('#google_translate_element').length) return;
$('body').append('<div id="google_translate_element" style="display:none;"></div>');
window.googleTranslateElementInit = function () {
new google.translate.TranslateElement({
pageLanguage: 'cs',
includedLanguages: 'cs,en',
autoDisplay: false
}, 'google_translate_element');
};
$.getScript('https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit');
}
createSwitcher();
loadGoogle();
// Reinforce switcher after translation DOM rewrite
setTimeout(createSwitcher, 2000);
});
});