981
pakeitimas
SNėra keitimo santraukos |
SNėra keitimo santraukos |
||
| (nerodomos 3 tarpinės versijos, sukurtos to paties naudotojo) | |||
| 1 eilutė: | 1 eilutė: | ||
(function() { | (function() { | ||
var isDark = document.cookie.includes('theme= | var isDark = !document.cookie.includes('theme=light'); | ||
if (isDark) { | if (isDark) { | ||
document.documentElement.classList.add('wgl-theme-dark', 'wgl-darkmode'); | document.documentElement.classList.add('wgl-theme-dark', 'wgl-darkmode'); | ||
| 11 eilutė: | 11 eilutė: | ||
var DARK_COOKIE = 'darkmode', | var DARK_COOKIE = 'darkmode', | ||
THEME_COOKIE = 'theme', | THEME_COOKIE = 'theme', | ||
isUsingDarkmode = $.cookie(THEME_COOKIE) | isUsingDarkmode = $.cookie(THEME_COOKIE) !== 'light', | ||
isMobile = mw.config.get('wgMFMode') !== null, | isMobile = mw.config.get('wgMFMode') !== null, | ||
portletLink; | portletLink; | ||
| 24 eilutė: | 24 eilutė: | ||
(isMobile ? 'p-navigation' : 'p-personal'), | (isMobile ? 'p-navigation' : 'p-personal'), | ||
'#', // Use '#' to prevent redirection | '#', // Use '#' to prevent redirection | ||
( | self.getToggleIcon(isUsingDarkmode), // Set initial icon based on current state | ||
'pt-dm-toggle', | 'pt-dm-toggle', | ||
'Toggle dark mode', | 'Toggle dark mode', | ||
| 30 eilutė: | 30 eilutė: | ||
$('#pt-userpage, #pt-anonuserpage, #pt-createaccount')[0] | $('#pt-userpage, #pt-anonuserpage, #pt-createaccount')[0] | ||
); | ); | ||
// Add pointer cursor style | |||
$(portletLink).css('cursor', 'pointer'); | |||
// Toggle theme on link click | // Toggle theme on link click | ||
| 41 eilutė: | 44 eilutė: | ||
self.applyTheme(isUsingDarkmode); | self.applyTheme(isUsingDarkmode); | ||
// | // Update link text with appropriate icon | ||
$(portletLink). | $(portletLink).html(self.getToggleIcon(isUsingDarkmode)); | ||
}); | }); | ||
}, | |||
// Helper function to get the appropriate icon based on current theme | |||
getToggleIcon: function(isDark) { | |||
if (isMobile) { | |||
return 'Toggle dark mode'; | |||
} else { | |||
return isDark ? '🌙 ' : '☀️ '; | |||
} | |||
}, | }, | ||