User:Nardog/dark-mode-toggle.js: Difference between revisions

Content deleted Content added
maybe this isn't needed
suggestions
Line 35:
function vectorStickyCallback() {
makePortletLink('p-personal-sticky-header', 'pt-darkmode-sticky-header', '#pt-watchlist-sticky-header');
$('#pt-darkmode-sticky-header span:only-child')
.prepend($('<span>').addClass('mw-ui-icon mw-ui-icon-vector-gadget-pt-darkmode'));
mw.hook('vector.page_title_scroll').remove(vectorStickyCallback);
}
Line 61 ⟶ 63:
 
// Toggle portlet link label and tooltip
var labelSelector;
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';
switch (mw.config.get('skin')) {
case 'vector':
case 'vector-2022':
case 'minerva':
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';
break;
default:
labelSelector = '#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'));
}
 
Line 101 ⟶ 113:
 
function savePreferenceLocally() {
mw.user.options.set('gadget-dark-mode', Number(isOn));
 
// In case the user navigates to another page too quickly
mw.storage.session.set('dark-mode-toggled', isOn ? '1' : '0');