Content deleted Content added
No edit summary |
No edit summary |
||
Line 21:
'es6-polyfills', 'oojs-ui.styles.icons-accessibility'
])).then(function () {
var
if (!state) return;
var isOn = state !== 'registered';
if (isOn) {
Line 33 ⟶ 35:
}
function getMsg(suffix) {
return mw.msg(key);
var tooltip = mw.msg('darkmode-turn-' + onOrOff + '-tooltip');▼
}
var label = getMsg('label');
var nextnode = mw.config.get('skin') !== 'minerva' && '#pt-watchlist';
var portletLink = mw.util.addPortletLink('p-personal', '#', label, 'pt-darkmode', tooltip, '', nextnode);
function toggleMode() {
isOn = !isOn;
var newState = Number(isOn);
new mw.Api().saveOption('gadget-dark-mode', newState);
▲ $('meta[name="theme-color"]').attr('content', newState ? '#000' : '#eaecf0');
mw.storage.session.set('dark-mode-toggled', newState);
// Toggle portlet link label and tooltip
$('#pt-darkmode, #pt-darkmode *').contents().each(function () {
// If it's a text node and has more than just whitespace
if (this.nodeType === 3 && /\S/.test(this.textContent)) {
this.textContent =
return false; // break
}
});
$('#pt-darkmode a').attr('title',
// Swap classes
Line 67 ⟶ 72:
if (gadgetsLinkElement) {
var uri = new mw.Uri(gadgetsLinkElement.href);
if (
uri.query.modules += ',dark-mode';
} else {
|