MediaWiki:Gadget-skinTogglesMobile.js: Difference between revisions

no edit summary
No edit summary
Tag: Manual revert
No edit summary
 
Line 1:
"use strict";
 
/**
* Toggles for skin cookies on mobile
Line 6 ⟶ 8:
*/
 
constvar DARK_COOKIE = 'darkmode';
var currentDark = $.cookie('theme') === 'dark' || ($.cookie('theme') == null && $.cookie(DARK_COOKIE) === 'true'),
darkPortletLink;
 
var self = {
init: function init() {
darkPortletLink = mw.util.addPortletLink('p-personal', '#', (currentDark ? 'Light' : 'Dark') + ' mode', 'wgl-darkmode-toggle', 'Toggle ' + (currentDark ? 'light' : 'dark') + ' mode', null, $('a.menu__item--logout').closest('li'));
darkPortletLink = mw.util.addPortletLink(
$('meta[name="theme-color"]').attr('content', currentDark ? '#071022' : '#c0a886');
'p-personal',
$.cookie(DARK_COOKIE'theme', currentDark, {expires:? 365,'dark' path: '/light'});, {
'#',
expires: 365,
(currentDark ? 'Light' : 'Dark') + ' mode',
path: '/'
'wgl-darkmode-toggle',
});
'Toggle ' + (currentDark ? 'light' : 'dark') + ' mode',
$(darkPortletLink).click(function (e) {
null,
e.preventDefault();
$('a.menu__item--logout').closest('li')
currentDark = !currentDark;
);
$('#wgl-darkmode-toggle .toggle-list-item__label').text((currentDark ? 'Light' : 'Dark') + ' mode');
$.cookie('meta[name="theme-color"]').attr('content', currentDark ? '#071022dark' : '#c0a886light');, {
expires: 365,
 
$.cookie('theme', currentDark ? 'dark' : 'light', {expires: 365, path: '/'});
});
$.cookie(DARK_COOKIE, currentDark, {
$(darkPortletLink).click(function (e) {
expires: 365,
e.preventDefault();
path: '/'
currentDark = !currentDark;
});
$('#wgl-darkmode-toggle .toggle-list-item__label').text((currentDark ? 'Light' : 'Dark') + ' mode');
$.cookie('meta[name="theme-color"]').attr('content', currentDark ? 'dark#071022' : 'light', {expires: 365, path: '/#c0a886'});
if (currentDark) {
$.cookie(DARK_COOKIE, currentDark, {expires: 365, path: '/'});
mw.loader.using(['wgl.theme.dark']).then(function () {
$('meta[name="theme-color"]').attr('content', currentDark ? '#071022' : '#c0a886');
$('body').addClass('wgl-theme-lightdark').removeClass('wgl-theme-darklight');
});
if (currentDark) {
} else {
mw.loader.using(['wgl.theme.dark']).then(function() {
$('body').addClass('wgl-theme-darklight').removeClass('wgl-theme-lightdark');
}
});
mw.notify('Switched to ' + (currentDark ? 'Lightdark' : 'Darklight') + ' mode!', {
} else {
tag: 'wg-darkmode-notification'
$('body').addClass('wgl-theme-light').removeClass('wgl-theme-dark')
});
}
});
mw.notify( 'Switched to ' + (currentDark ? 'dark' : 'light') + ' mode!', { tag: 'wg-darkmode-notification' } );
}
});
},;
}
 
$(self.init);