Открыть меню
Переключить меню настроек
Открыть персональное меню
Вы не представились системе
Ваш IP-адрес будет виден всем, если вы внесёте какие-либо изменения.

MediaWiki:Common.js: различия между версиями

Страница интерфейса MediaWiki
Нет описания правки
Нет описания правки
Строка 56: Строка 56:
mw.loader.using('mediawiki.util', function () {
mw.loader.using('mediawiki.util', function () {
   $(function () {
   $(function () {
     $('.collapsible-header').each(function () {
     $('.colstr-header').each(function () {
       $(this).on('click', function () {
       $(this).on('click', function () {
         const $panel = $(this).closest('.collapsible-panel');
         const $panel = $(this).closest('.colstr-panel');
         const isOpen = $panel.toggleClass('open').hasClass('open');
         const isOpen = $panel.toggleClass('open').hasClass('open');
         $(this).attr('aria-expanded', isOpen);
         $(this).attr('aria-expanded', isOpen);

Версия от 03:44, 4 августа 2025

const pageName = mw.config.get("wgPageName");

if (pageName != "Шаблон:Таблица_Космический_Закон") {
    let current = null;
    let currentCell = null;
    const table = document.getElementById("law");
    if (table) {
        table.addEventListener("click", function (event) {
        const cell = event.target.closest("td");
        if (!cell) return;
        if (!cell.dataset.id) return;
    
        if (current !== null) {
            document.getElementById(current).style.display = "none";
            if (currentCell) currentCell.classList.remove("law-selected");
        }
        
        if (cell.dataset.id === current) {
            current = null;
            currentCell = null;
            return;
        }
        
        current = cell.dataset.id;
        currentCell = cell;
        
        document.getElementById(current).style.display = "block";
        cell.classList.add("law-selected");
        });
    }
} else {
    const allObjects = document.querySelectorAll(".law-object");
    allObjects.forEach(el => el.style.display = "block");
}

mw.loader.using('jquery', function () {
  $(function () {
    $('.vtabs').each(function () {
      const $container = $(this);
      const $buttons = $container.find('.vtabs-button');
      const $contents = $container.find('.vtabs-content');

      $buttons.each(function (index) {
        $(this).on('click', function () {
          $buttons.removeClass('active');
          $contents.removeClass('active');

          $(this).addClass('active');
          $contents.eq(index).addClass('active');
        });
      });
    });
  });
});

mw.loader.using('mediawiki.util', function () {
  $(function () {
    $('.colstr-header').each(function () {
      $(this).on('click', function () {
        const $panel = $(this).closest('.colstr-panel');
        const isOpen = $panel.toggleClass('open').hasClass('open');
        $(this).attr('aria-expanded', isOpen);
      });
    });
  });
});