мНет описания правки Метка: отменено |
мНет описания правки Метка: отменено |
||
Строка 1: | Строка 1: | ||
// Создаем кнопку "Меню" для мобильных | |||
$(document).ready(function() { | |||
if (window.matchMedia("(max-width: 768px)").matches) { | |||
var menuHtml = '<button class="mobile-menu-toggle">☰ Меню</button>'; | |||
$('.citizen-header__start').append(menuHtml); | |||
// Открытие/закрытие меню | |||
$('.mobile-menu-toggle').click(function() { | |||
$('.citizen-header__end').toggle(); | |||
}); | |||
} | |||
}); | |||
window.toggleTheme = function() { | window.toggleTheme = function() { | ||
document.body.classList.toggle('dark-theme'); | document.body.classList.toggle('dark-theme'); |
Версия от 16:24, 1 апреля 2025
// Создаем кнопку "Меню" для мобильных
$(document).ready(function() {
if (window.matchMedia("(max-width: 768px)").matches) {
var menuHtml = '<button class="mobile-menu-toggle">☰ Меню</button>';
$('.citizen-header__start').append(menuHtml);
// Открытие/закрытие меню
$('.mobile-menu-toggle').click(function() {
$('.citizen-header__end').toggle();
});
}
});
window.toggleTheme = function() {
document.body.classList.toggle('dark-theme');
localStorage.setItem('theme', document.body.classList.contains('dark-theme') ? 'dark' : 'light');
};
document.addEventListener('DOMContentLoaded', function() {
var savedTheme = localStorage.getItem('theme');
if (savedTheme === 'dark') document.body.classList.add('dark-theme');
});
mw.hook('citizen.load').add(function() {
var button = document.createElement('button');
button.textContent = '🌓 Тема';
button.style.cssText = 'margin: 0 10px; padding: 8px 12px; cursor: pointer;';
button.onclick = toggleTheme;
var headerTools = document.querySelector('.citizen-header__tools');
if (headerTools) {
headerTools.insertBefore(button, headerTools.firstChild);
}
});
// Отключаем регистрацию Service Worker
if ('serviceWorker' in navigator) {
navigator.serviceWorker.getRegistrations().then(function(registrations) {
for (var i = 0; i < registrations.length; i++) { // Исправлено: ES5-совместимый цикл
registrations[i].unregister();
}
});
}