MediaWiki:Gadget-dark-mode-toggle.js: Difference between revisions

Content deleted Content added
sync update requested from User:TheDJ/Gadget-dark-mode-toggle.js
requested updates from User:Nardog/dark-mode-toggle.js
Line 17:
}
 
$.when($.ready, mw.loader.using(['mediawiki.util', 'mediawiki.api', 'mediawiki.Uri', 'mediawiki.storage', 'es6-polyfills'])).then(function () {
var isOn = !!mw.user.options.get('gadget-dark-mode');
 
Line 26:
document.documentElement.classList.add('client-dark-mode');
// Update the initial minervamobile theme-color
$('meta[name="theme-color"]').attr('content', '#000000');
}
Line 48:
 
// Toggle portlet link label and tooltip
var labelSelector = ['vector', 'vector-2022', 'minerva'].includes(mw.config.get('skin')) ? '#pt-darkmode span:not(.mw-ui-icon)' : '#pt-darkmode a';
$(labelSelector).text(mw.msg('darkmode-turn-' + onOrOff + '-label'));
$('#pt-darkmode a').attr('title', mw.msg('darkmode-turn-' + onOrOff + '-tooltip'));
// Update the minervamobile theme-color
$('meta[name="theme-color"]').attr('content', newState ? '#000000' : '#eaecf0' );
 
Line 78:
}
 
$(portletLink).on('click', function (e) {
e.preventDefault();
toggleMode();
Line 100:
toggleMode();
}
mw.requestIdleCallback(function () {
mw.storage.set('dark-mode-system-scheme', Number(systemSchemeNow));
});