891
pakeitimas
Nėra keitimo santraukos |
Nėra keitimo santraukos |
||
| (nerodomos 3 tarpinės versijos, sukurtos to paties naudotojo) | |||
| 1 eilutė: | 1 eilutė: | ||
(function() { | |||
var isDark = document.cookie.includes('theme=dark'); | |||
if (isDark) { | |||
document.documentElement.classList.add('wgl-theme-dark', 'wgl-darkmode'); | |||
} else { | |||
document.documentElement.classList.add('wgl-theme-light', 'wgl-lightmode'); | |||
} | |||
})(); | |||
(function($, mw) { | (function($, mw) { | ||
var DARK_COOKIE = 'darkmode', | var DARK_COOKIE = 'darkmode', | ||
| 15 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', | ||
| 21 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 | ||
| 32 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 ? '🌙 ' : '☀️ '; | |||
} | |||
}, | }, | ||