MediaWiki:Common.js: відмінності між версіями

Матеріал з Країнопедії
(Page Tools: примусово pinned-enabled через body class — Vector підхопить)
(revert: остаточно прибираю JS body-class flip)
Мітка: Ручний відкіт
Рядок 38: Рядок 38:
     });
     });
   });
   });
});
// Force Page Tools (правий sidebar Інструменти) завжди pinned-enabled
// Перебиваємо body class — Vector сам підхопить всі правильні стилі pinned-режиму.
$(function () {
  if (document.body.classList.contains("vector-feature-page-tools-pinned-disabled")) {
    document.body.classList.remove("vector-feature-page-tools-pinned-disabled");
    document.body.classList.add("vector-feature-page-tools-pinned-enabled");
  }
});
});

Версія за 01:09, 4 травня 2026

mw.loader.using(["mediawiki.util"], function () {
  $(function () {
    var pageName = mw.config.get("wgPageName") || "";
    console.log("[nomadica] common.js v6, wgPageName =", pageName);
    if (pageName !== "🇷🇴_Румунія") return;

    var cities = [
      { title: "Бухарест", page: "Румунія/Бухарест" },
      { title: "Клуж-Напока", page: "Румунія/Клуж-Напока" },
      { title: "Тімішоара", page: "Румунія/Тімішоара" },
      { title: "Брашов", page: "Румунія/Брашов" },
      { title: "Ясси", page: "Румунія/Ясси" },
      { title: "Сібіу", page: "Румунія/Сібіу" }
    ];

    // Спробувати вставити перед #p-tb (TOOLBOX) — стандартний хвостовий портлет.
    // Якщо нема — після #p-navigation.
    var portlet = null;
    if (document.getElementById("p-tb")) {
      portlet = mw.util.addPortlet("p-cities", "Міста", "#p-tb");
      console.log("[nomadica] inserted before #p-tb");
    }
    if (!portlet) {
      portlet = mw.util.addPortlet("p-cities", "Міста");
      var nav = document.getElementById("p-navigation");
      if (nav && nav.parentNode) {
        nav.parentNode.insertBefore(portlet, nav.nextSibling);
        console.log("[nomadica] manually inserted after #p-navigation");
      } else {
        console.log("[nomadica] FAILED to find anchor for portlet");
        return;
      }
    }

    cities.forEach(function (city) {
      var link = mw.util.addPortletLink("p-cities", mw.util.getUrl(city.page), city.title);
      console.log("[nomadica] addPortletLink", city.title, "→", link ? "OK" : "FAIL");
    });
  });
});