Proyectos de Subversion Moodle

Rev

Rev 738 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 738 Rev 1441
Línea 21... Línea 21...
21
// @copyright  Copyright © 2021 onwards Marcin Czaja Rosea Themes
21
// @copyright  Copyright © 2021 onwards Marcin Czaja Rosea Themes
22
//
22
//
23
// @license    Commercial
23
// @license    Commercial
Línea 24... Línea 24...
24
 
24
 
25
/* jshint ignore:start */
25
/* jshint ignore:start */
26
define(["jquery", "core_user/repository"], function ($, UserRepository) {
26
define(['jquery', 'core/aria', 'core_user/repository'], function ($, setUserPreference, UserRepository) {
Línea 27... Línea 27...
27
  "use strict";
27
    "use strict"; // ...jshint ;_; !!!
28
 
28
 
29
  return {
29
    return {
-
 
30
        init: function () {
30
    init: function () {
31
            $(document).ready(function ($) {
31
      $(document).ready(function () {
-
 
32
        var trigger = $("#darkModeBtn");
32
                
33
        if (trigger.length) {
33
                var trigger = $(document.getElementById("darkModeBtn"));
34
          var preference = trigger.attr("data-preference");
34
                var preference = trigger.attr('data-preference');
-
 
35
 
35
 
36
                $('#darkModeBtn').click(function () {
36
          trigger.click(function () {
37
                    if ($('body').hasClass('theme-dark')) {
-
 
38
                        $('body').removeClass('theme-dark');
-
 
39
                        $('html').removeClass('dark-mode');
-
 
40
                        trigger.attr('aria-checked', 'false');
37
            $("body").toggleClass("theme-dark");
41
                        UserRepository.setUserPreference(preference, false);
-
 
42
                    } else {
38
            $("html").toggleClass("dark-mode");
43
                        $('body').addClass('theme-dark');
39
            var isDarkMode = $("body").hasClass("theme-dark");
44
                        $('html').addClass('dark-mode');
-
 
45
                        trigger.attr('aria-checked', 'true');
-
 
46
                        UserRepository.setUserPreference(preference, true);
-
 
47
                    }
-
 
48
                });
-
 
49
 
-
 
50
                $('#courseIndexBtn').click(function () {
-
 
51
                    if ($('body').hasClass('drawer-open-index--open')) {
-
 
52
                        $('body').removeClass('drawer-courseindex--open');
-
 
53
                        $('body').removeClass('drawer-open-index--open');
-
 
54
                    } else {
-
 
55
                        $('body').toggleClass('drawer-courseindex--open');
-
 
56
                    }
-
 
57
                });
-
 
58
 
-
 
59
                $('.drawertoggle').click(function () {
-
 
60
                    if ($('body').hasClass('drawer-open-index--open')) {
-
 
61
                        $('body').removeClass('drawer-courseindex--open');
-
 
62
                        $('body').removeClass('drawer-open-index--open');
-
 
63
                    } else {
-
 
64
                        $('body').toggleClass('drawer-courseindex--open');
-
 
65
                    }
-
 
66
                });
-
 
67
 
-
 
68
                $('#courseindexbtn, .bulkEnable').click(function () {
-
 
69
                    $(function () {
-
 
70
                        $('#course-tab2').tab('show');
-
 
71
                    });                    
-
 
72
                });
-
 
73
 
-
 
74
                $( document ).ready(function() {
-
 
75
                    if ($("body.drawer-open-index--open, body.drawer-courseindex--open").length) {
-
 
76
                        $('#course-tab2').tab('show');
-
 
77
                    }
-
 
78
                });
-
 
79
 
-
 
80
                $('#mobileNav, .rui-mobile-nav-btn-close').click(function () {
-
 
81
                    $('#topBar').toggleClass('opened');
-
 
82
                });
-
 
83
 
-
 
84
                $("#showBlockArea").on("click", function () {
40
            trigger.attr("aria-checked", isDarkMode.toString());
85
                    $('body').toggleClass('rui-edit-areas');
-
 
86
                    $('#showBlockArea').toggleClass('active');
-
 
87
                });
-
 
88
 
-
 
89
                $('.rui-nav--admin .nav-link').each(function () {
-
 
90
                    var text = $(this).html();
-
 
91
                    $(this).html(text.replace('(', '<span class="mt-1 small d-block">'));
-
 
92
                });
-
 
93
                $('.rui-nav--admin .nav-link').each(function () {
-
 
94
                    var text = $(this).html();
41
            UserRepository.setUserPreference(preference, isDarkMode);
95
                    $(this).html(text.replace(')', '</span>'));
Línea 42... Línea -...
42
          });
-
 
43
        }
-
 
44
 
-
 
45
        function toggleDrawer() {
-
 
46
          $("body").toggleClass(
96
                });
47
            "drawer-courseindex--open drawer-open-index--open"
-
 
48
          );
-
 
49
        }
-
 
50
 
-
 
51
        $(".btn-drawer--left, .drawertoggle").click(toggleDrawer);
-
 
52
 
-
 
53
        $("#courseindexbtn, .bulkEnable").click(function () {
-
 
54
          $("#course-tab2").tab("show");
-
 
55
        });
-
 
56
 
-
 
57
        if ($("body").hasClass("drawer-courseindex--open")) {
-
 
58
          $("#course-tab2").tab("show");
-
 
59
        }
-
 
60
 
-
 
61
        $("#mobileNav, .rui-mobile-nav-btn-close").click(function () {
-
 
62
          $("#topBar").toggleClass("opened");
-
 
63
        });
-
 
64
 
-
 
65
        $("#showBlockArea").click(function () {
-
 
66
          $("body").toggleClass("rui-edit-areas");
-
 
67
          $(this).toggleClass("active");
-
 
68
        });
-
 
69
 
-
 
70
        $(".rui-nav--admin .nav-link").each(function () {
-
 
71
          var text = $(this).html();
-
 
72
          $(this).html(
-
 
73
            text
-
 
74
              .replace("(", '<span class="mt-1 small d-block">')
-
 
75
              .replace(")", "</span>")
-
 
76
          );
97
            });
77
        });
-
 
78
      });
98
 
79
    },
-
 
80
  };
99
        }