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

Content deleted Content added
Implementing changes requested on talk page (diff, permalink) for an interface admin.
Line 34:
var tooltip = mw.msg('darkmode-turn-' + onOrOff + '-tooltip');
var nextnode = mw.config.get('skin') !== 'minerva' && '#pt-watchlist';
var portletLink = mw.util.addPortletLink('p-personal', '#', label, 'pt-darkmode', tooltip, '', nextnode);
mw.util.addPortletLink('p-personal-sticky-header', '#', label, 'pt-darkmode-sticky-header', tooltip, '', nextnode + '-sticky-header');
 
function toggleMode() {
Line 48 ⟶ 49:
 
// 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-sticky-header span:not(.mw-ui-icon)' : '#pt-darkmode a';
$(labelSelector).text(mw.msg('darkmode-turn-' + onOrOff + '-label'));
$('#pt-darkmode a, #pt-darkmode-sticky-header a').attr('title', mw.msg('darkmode-turn-' + onOrOff + '-tooltip'));
// Update the mobile theme-color
$('meta[name="theme-color"]').attr('content', newState ? '#000000' : '#eaecf0' );
 
// Modify the <link> element on the page to include/exclude dark-mode styles
Line 83 ⟶ 84:
}
 
$(portletLink'#pt-darkmode, #pt-darkmode-sticky-header').on('click', function (e) {
e.preventDefault();
toggleMode();