MediaWiki:Common.js: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 427: Line 427:


     $('#dark-mode-switch').click(function () {
     $('#dark-mode-switch').click(function () {
        var state = $('body').hasClass('dark-mode') ? 'off' : 'on';
        $(this).after('<div class="dark-mode-notif" data-state="'+state+'"></div>');
         $('body').toggleClass('dark-mode');
         $('body').toggleClass('dark-mode');
        var otherNotif = $('.dark-mode-notif:not(:eq(0))');
        otherNotif.remove();
        var notif = $('.dark-mode-notif:eq(0)');
        notif.show();
        setTimeout(function(){
            notif.removeClass('toast-visible');
            setTimeout(function(){
                notif.remove();
            }, 300);
        }, 3000);
         matchHeaderText(true);
         matchHeaderText(true);
         if ($('body').hasClass('dark-mode')) {
         if ($('body').hasClass('dark-mode')) {
Line 446: Line 434:
             setCookie('elwiki-dark-mode', 'false');
             setCookie('elwiki-dark-mode', 'false');
         }
         }
       
     });
     });