MediaWiki:Common.js: відмінності між версіями
Wiki (обговорення | внесок) Немає опису редагування |
Wiki (обговорення | внесок) Немає опису редагування |
||
| Рядок 1: | Рядок 1: | ||
$(function () { | $(function () { | ||
var themes = { | var themes = { | ||
light: '/w/index.php?title=MediaWiki:Light.css&action=raw&ctype=text/css', | light: '/w/index.php?title=MediaWiki:Light.css&action=raw&ctype=text/css', | ||
| Рядок 8: | Рядок 5: | ||
}; | }; | ||
var theme = localStorage.getItem('selectedTheme'); | var theme = localStorage.getItem('selectedTheme'); | ||
if (!theme) { | if (!theme) { | ||
theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; | theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; | ||
} | } | ||
if (themes[theme]) { | if (themes[theme]) { | ||
mw.loader.load(themes[theme], 'text/css'); | mw.loader.load(themes[theme], 'text/css'); | ||
} | } | ||
var $btn = $('<button>') | var $btn = $('<button>') | ||
.text(theme === 'dark' ? ' Світла тема ☀️' : ' Темна тема 🌙') | .text(theme === 'dark' ? 'Світла тема ☀️' : 'Темна тема 🌙') | ||
.attr('title', 'Змінити тему') | .attr('title', 'Змінити тему') | ||
.css({ | .css({ | ||
| Рядок 29: | Рядок 22: | ||
bottom: '10px', | bottom: '10px', | ||
right: '10px', | right: '10px', | ||
padding: '10px 16px', // більше простору для тексту | |||
padding: ' | |||
border: 'none', | border: 'none', | ||
borderRadius: ' | borderRadius: '25px', // овальна форма | ||
background: '#1a73e8', | background: '#1a73e8', | ||
color: '#ffffff', | color: '#ffffff', | ||
fontWeight: 'bold', | fontWeight: 'bold', | ||
fontSize: '14px', | fontSize: '14px', | ||
| Рядок 41: | Рядок 32: | ||
zIndex: 9999, | zIndex: 9999, | ||
textAlign: 'center', | textAlign: 'center', | ||
boxShadow: '0 2px 6px rgba(0,0,0,0.3)', | |||
boxShadow: '0 2px 6px rgba(0,0,0,0.3)' | whiteSpace: 'nowrap' // текст не переноситься | ||
}) | }) | ||
.click(function () { | .click(function () { | ||
var newTheme = theme === 'dark' ? 'light' : 'dark'; | var newTheme = theme === 'dark' ? 'light' : 'dark'; | ||
localStorage.setItem('selectedTheme', newTheme); | localStorage.setItem('selectedTheme', newTheme); | ||