MediaWiki:Common.js: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 5: | Строка 5: | ||
function loadTheme() { | function loadTheme() { | ||
const saved = $.cookie(COOKIES.THEME); | const saved = $.cookie(COOKIES.THEME); | ||
return saved || | return saved || 'normal'; | ||
} | } | ||
| Строка 15: | Строка 15: | ||
function applyTheme(theme) { | function applyTheme(theme) { | ||
$('body') | $('body') | ||
.removeClass('wgl-theme-light wgl-theme-dark') | .removeClass('wgl-theme-normal wgl-theme-light wgl-theme-dark') | ||
.addClass(`wgl-theme-${theme}`); | .addClass(`wgl-theme-${theme}`); | ||
mw.hook('wgl.themeChanged').fire(theme); | mw.hook('wgl.themeChanged').fire(theme); | ||
| Строка 33: | Строка 33: | ||
const themes = [ | const themes = [ | ||
{ key: 'light', label: 'Белая тема' }, | { key: 'light', label: 'Белая тема' }, | ||
{ key: 'dark', | { key: 'normal', label: 'Стандартная тема' }, | ||
{ key: 'dark', label: 'Чёрная тема' } | |||
]; | ]; | ||
themes.forEach(item => { | themes.forEach(item => { | ||
| Строка 51: | Строка 52: | ||
$list.append($item); | $list.append($item); | ||
$menuContent.append($list); | $menuContent.append($list); | ||
$portlet.append($heading, $menuContent); | $portlet.append($heading, $menuContent); | ||
$container.append($portlet); | $container.append($portlet); | ||
| Строка 61: | Строка 61: | ||
}); | }); | ||
} | } | ||
const initialTheme = loadTheme(); | |||
applyTheme(initialTheme); | |||
mw.themeUtils = { loadTheme, applyTheme, initThemeMenu }; | mw.themeUtils = { loadTheme, applyTheme, initThemeMenu }; | ||