MediaWiki:Common.js: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 5: | Строка 5: | ||
var STORAGE_KEY = 'wiki-theme', | var STORAGE_KEY = 'wiki-theme', | ||
theme = null, | theme = null, | ||
portletLink; | |||
function applyTheme(name) { | function applyTheme(name) { | ||
| Строка 18: | Строка 17: | ||
console.warn('Не удалось сохранить тему в localStorage:', e); | console.warn('Не удалось сохранить тему в localStorage:', e); | ||
} | } | ||
} | } | ||
| Строка 39: | Строка 30: | ||
applyTheme(theme); | applyTheme(theme); | ||
portletLink = mw.util.addPortletLink( | |||
mw.config.get('wgMFMode') !== null ? 'p-navigation' : 'p-personal', | |||
'#', | |||
'Переключить тему', | |||
'pt-theme-toggle', | |||
'Переключить светлую/тёмную тему' | |||
); | |||
$(portletLink).find('a').on('click', function (e) { | |||
e.preventDefault(); | |||
theme = (theme === 'dark') ? 'light' : 'dark'; | |||
applyTheme(theme); | |||
}); | |||
} | } | ||