Přeskočit na obsah

MediaWiki:Common.js

Z The Last Kingdom UO Wiki

Poznámka: Po zveřejnění musíte vyprázdnit cache vašeho prohlížeče, jinak změny neuvidíte.

  • Firefox / Safari: Při kliknutí na Aktualizovat držte Shift nebo stiskněte Ctrl-F5 nebo Ctrl-R (na Macu ⌘-R)
  • Google Chrome: Stiskněte Ctrl-Shift-R (na Macu ⌘-Shift-R)
  • Edge: Při kliknutí na Aktualizovat držte Ctrl nebo stiskněte Ctrl-F5.
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);

  });
});

mw.loader.using(['mediawiki.util'], function () {
  $(function () {

    function expandSidebar() {
      if (window.innerWidth >= 1000) {
        document.body.classList.remove('vector-main-menu-hidden');
        document.body.classList.remove('vector-main-menu-collapsed');
      }
    }

    expandSidebar();
    window.addEventListener('resize', expandSidebar);

  });
});